package com.qianclass.talklive.app.json.ImSendMessge;

import com.google.gson.Gson;
import com.qianclass.talklive.app.bean.AuthOpenFile;
import com.qianclass.talklive.app.bean.WhiteBoardBean;
import com.qianclass.talklive.app.im.IMEgine;
import com.qianclass.talklive.app.utils.Constant;
import com.qianclass.talklive.app.utils.LogUtil;
import com.qianclass.talklive.app.utils.ThreadUtils;

/**
 * Created by Admin on 2017/3/13.
 */

public class SendOpenFileMessge {

    //发送打开共享的文件命令
    public static void sendMessge(int FileID, String FileName, String FileDir, int pageNum,
                                  final IMEgine egine, final String group){
        AuthOpenFile authOpenFile = new AuthOpenFile();

        AuthOpenFile.MessageBean messageBean = new AuthOpenFile.MessageBean();
        messageBean.setType("whiteboard");

        WhiteBoardBean whiteboardBean = new WhiteBoardBean();
        whiteboardBean.setSubcommand("openfile");
        whiteboardBean.setFileid(FileID);
        whiteboardBean.setFilename(FileName);
        whiteboardBean.setPagenum(pageNum);
        whiteboardBean.setCurrentpage(1);
        whiteboardBean.setDocserver(Constant.getDocUrl());
        whiteboardBean.setDomain(Constant.getMP3URL());
        whiteboardBean.setFiledir(FileDir);
        whiteboardBean.setDocid(FileID + "");

        messageBean.setWhiteboard(whiteboardBean);
        authOpenFile.setMessage(messageBean);

        Gson gson = new Gson();
        final String jsonString = gson.toJson(authOpenFile);
        ThreadUtils.runOnSubThread(new Runnable() {
            @Override
            public void run() {
                egine.SendGroupMessage(Constant.WHITEBOARDMSGTYPE, group, jsonString);
            }
        });
        LogUtil.i("发送打开共享的文件命令" ,jsonString);
    }
}
